package com.yuanzong.wuliu.service.system.apk.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanzong.wuliu.common.vo.ApiResultPage;
import com.yuanzong.wuliu.mapper.system.apk.SystemApkMapper;
import com.yuanzong.wuliu.model.system.apk.SystemApk;
import com.yuanzong.wuliu.model.system.apk.query.*;
import com.yuanzong.wuliu.service.system.apk.ISystemApkService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service("systemApkService")
public class SystemApkServiceImpl extends ServiceImpl<SystemApkMapper, SystemApk> implements ISystemApkService {

    // 逻辑删除
    protected static final boolean logicalDeleted = false;

    @Autowired
    private SystemApkMapper systemApkMapper;

    //========================================================================================//
    // Service服务接口操作
    //========================================================================================//

    @Override
    public List<SystemApk> querySubject(SystemApkListQuery query) throws Exception {
        List<SystemApk> systemApkList = null;
        QueryWrapper<SystemApk> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        systemApkList = super.getBaseMapper().selectList(queryWrapper);
        return systemApkList;
    }

    @Override
    public ApiResultPage<SystemApk> pageSubject(SystemApkPageQuery query) throws Exception {
        ApiResultPage<SystemApk> systemApkPageList = null;
        Page<SystemApk> systemApkPage = new Page<>(query.getPageNum(), query.getPageSize());
        QueryWrapper<SystemApk> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("create_time");
        systemApkPage = super.baseMapper.selectPage(systemApkPage, queryWrapper);
        systemApkPageList = ApiResultPage.create(query.getPageNum(), query.getPageSize(), systemApkPage);
        return systemApkPageList;
    }

    //========================================================================================//
    // HTTP服务接口操作
    //========================================================================================//

    //========================================================================================//
    // extend methods
    //========================================================================================//


    //========================================================================================//
    // The end
    //========================================================================================//

}
